//
//  UIImage+CLBasic64.m
//  Rippton_iphone
//
//  Created by yeyongping on 2017/11/7.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UIImage+CLBasic64.h"

@implementation UIImage (CLBasic64)
- (NSString *)imageToBasic64String{
    NSData *data = UIImageJPEGRepresentation(self, 0.5);
    return  [data base64EncodedStringWithOptions:kNilOptions];
}

+ (instancetype)cl_imageWithBundleName:(NSString *)bundleName imageName:(NSString *)imageName{
    NSString *bundlePath = [[ NSBundle mainBundle] pathForResource:bundleName ofType :@"bundle"];
    NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
    NSString *img_path = [bundle pathForResource:imageName ofType:@"png"];
    UIImage *image=[UIImage imageWithContentsOfFile:img_path];
    return image;
}


+ (UIImage *)basic64StringToImage:(NSString *)basic64String{
    if (basic64String.length == 0) {
        return nil;
    }
    NSData *decodeData = [[NSData alloc] initWithBase64EncodedString:basic64String options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
    UIImage *decodedImage = [UIImage imageWithData: decodeData];
    return decodedImage;
}



@end
